<?php
/**
 * this class provieds some useful functions to generate js variables, and include js files
 * from php
 * 
 * @author		simon ungerboeck <ungerboeck_simon@hotmail.com>
 * @version		1.0
 */

class DynamicJS{
	private $variables;
	private $files;
	public function __construct(){
		$this->variables = '';
		$this->files = '';
	}
	
	/**
	 * generates an string for the variables
	 * @param 		array		 $variables
	 */
	public function initVariables($variables){
		foreach ($variables as $var => $value)
			$this->variables .= 'var ' . $var . ' = "' . $value . '";';
	}
	
	
	/**
	 * generates an string for the files
	 * @param 		array		 $files
	 */
	public function initFiles($files){
		foreach($files as $file)
			$this->files .= '<script src="' . $file . '" type="text/javascript" language="javascript"></script>';		
	}
	
	
	/**
	 * generates the output
	 * @return		string		
	 */
	public function generateJSOutput(){
		return ($this->files . '<script type="text/javascript" language="javascript">' . $this->variables . '</script>');
	}
}
?>